<%@ page import="ar.com.niktutos.dto.CapituloDTO" %>
<%@ page import="ar.com.niktutos.dto.TagDTO" %>

<%	

	
	ar.com.niktutos.web.TutoPlayer tutoPlayer = new ar.com.niktutos.web.TutoPlayer();
	
	String t = request.getParameter("t");

	CapituloDTO capitulo = null;
	if(t!=null){
        try {
            Integer.parseInt(t);
            capitulo = tutoPlayer.getCapituloByNumber(t);
        } catch (NumberFormatException ex) {
        	capitulo = tutoPlayer.getLastCapitulo();
        }
		if(capitulo==null)
			capitulo = tutoPlayer.getLastCapitulo();
	}else
		capitulo = tutoPlayer.getLastCapitulo();
	
	
	
%>
<!DOCTYPE html>
<html lang="es">
	<jsp:include page="header.jsp"/>
	<body onLoad="capitulo._capituloNumero = <% out.print(capitulo.getNumeroCapitulo()); %>;setTutoEvents();">
	<div id="fb-root"></div>
	<script>(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));</script>
	<script type="text/javascript" src="js/tutoPlayer.js"></script>
		<jsp:include page="menu.jsp"/>
		<div id="body">
		    <div id="main">
				<div id="tutoPlayer">
					<div id="capBar">
	
					    <div id="capSelector">
							<%
								out.print(tutoPlayer.getHTMLCapitulos());
							%>
					    </div>
					</div>			
					
					<div id="innerTutoPlayer">
						<div style="margin-bottom: 20px;">
							<input id="capSearch" /><div id="searchButton"><div id="lupa" ></div></div>
						</div>
						<div id="capName"><% out.print(capitulo.getNombre()); %></div>
						<div id="nextCap" class="arrow" style=\"margin-right:5px\"><a href="tutoPlayer?t=<% out.print(capitulo.getNumeroCapitulo()+1); %>">Siguiente ></a></div>
						<div id="previousCap" class="arrow"><a href="tutoPlayer?t=<% out.print(capitulo.getNumeroCapitulo()-1); %>">< Anterior</a></div>
						<iframe id="tuto" style="margin-left: 5px;margin-top: 5px;" width="560" height="315" src="<% out.print(capitulo.getUrl()); %>" frameborder="0" allowfullscreen></iframe>
						<div id="capDescription"><% out.print(capitulo.getDescripcion()); %></div>
						<div id="capLinks">
							<div id="code">
								Codigo
							</div>
							<!-- <div id="comment">
								Comentar
							</div>-->
							<div id="tags">
								<%
									for(TagDTO tag:capitulo.getTags())
										out.print("<div>"+tag.getDescripcion()+"</div>");
								%>
							</div>
						</div>
						<div id="outterFBComments">
							<div class="fb-comments" data-href="tutoPlayer?t=<% out.print(capitulo.getNumeroCapitulo()); %>" data-num-posts="10" data-width="560"></div>
						</div>
					</div>
					<div style="float:left;width: 160px;height: 600px;margin-left: 5px;" id="publicidadTuto">
						<script type="text/javascript"><!--
						google_ad_client = "ca-pub-8099025589228365";
						/* tutoPlayerAdsense */
						google_ad_slot = "5416719275";
						google_ad_width = 468;
						google_ad_height = 60;
						//-->
						</script>
						<script type="text/javascript"
						src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
						</script>
					</div>
					
				</div>
			</div>
		</div>
	</body>
</html>